﻿using Microsoft.Extensions.Configuration;
using OAS.Application.MenuApp.Dtos;
using OAS.Core;

namespace OAS.Application;

/// <summary>
/// 系统服务接口
/// </summary>
public class SystemAppService : IDynamicApiController
{
    private readonly ISqlSugarClient db;
    private readonly ISystemService _systemService;
    public SystemAppService(ISystemService systemService, ISqlSugarClient db)
    {
        _systemService = systemService;
        this.db = db;
    }

    /// <summary>
    /// 生成实体类
    /// </summary>
    /// <returns></returns>
    public void CreateEntity()
    {
        var tbs = db.DbMaintenance.GetTableInfoList();
        tbs.ForEach(tb =>
        {
            db.MappingTables.Add(tb.Name.Split("_")[1], tb.Name);
        });
        db.DbFirst.IsCreateAttribute().IsCreateDefaultValue().CreateClassFile(App.Configuration["GenerateEntityPath"], "OAS.Core");
    }
}
